<html lang="en">
<body>
    <link rel="stylesheet" href="/css/common.css" type="text/css">
    <div style="text-align: center; width: 100%; height: 100%">
        <span class="object-top-header">诗词项目</span>
        <span class="object-top-line object-top-main-page href-next" onclick="mainPage()">主页</span>
        <span class="object-top-line object-top-last-page href-next" onclick="lastPage()">返回</span>
        <span id="user" class="object-top-line object-top-user href-next"></span>
        <span class="object-top-line object-top-logout href-next" onclick="logout()">退出登录</span>
    </div>
    <script src="/js/jquery/jquery-3.4.1.js"></script>
    <script src="/js/service/common.js"></script>
    <script>
        function mainPage(){
            window.parent.location.href = "/page/service/index";
        }
        window.onload = () => {
            let obj = $("#user");
            let user = getUser();
            if(user){
                obj.html(user.username);
                obj.click(() => userDetailById(user.id));
            }else{
                $.ajax({
                    url: "/page/currentUser",
                    dataType: "json",
                    type: "GET",
                    success: function (res) {
                        let name = res.username;
                        let id = res.id;
                        res = JSON.stringify(res);
                        sessionStorage.setItem(CURRENT_USER, res);
                        obj.html(name);
                        obj.click(() => userDetailById(id));
                    }
                });
            }
        }
    </script>
</body>
</html>